<!--
 * :Author: Alice.fang
 * :Date: 2022-10-14 14:33:27
 * :LastEditors: Alice.fang
 * :LastEditTime: 2022-10-28 11:58:02
 * :Description: web ui layout
-->
<template>
    <div>
        <template v-if="!isOneself">
            <div class="top"></div>
            <div class="app-wrapper">
                <div class="mainArea">
                    <div id="leftBar" class="leftBar" :style="{ height: windowSize.height + 'px' }">
                        <div class="system-title">
                            <div class="image">
                                <img src="../assets/images/logo/logotype.png" alt="" srcset="" />
                            </div>
                            <div class="closeBtn">
                                <img src="../assets/images/ic_close@3.png" alt="" srcset="" @click="closeNav()" />
                            </div>
                        </div>
                        <div class="sidebar-container" :style="{ height: windowSize.width >= 1274 ? windowSize.height - 94 + 'px' : windowSize.height - 84 + 'px' }">
                            <ElMenu @parentCloseNav="closeNav" />
                        </div>
                    </div>

                    <div class="main-container" id="main-container">
                        <HeaderNav @parentOpenNav="openNav" class="header-main" />
                        <div class="app-main" :style="{ height: windowSize.height - 94 + 'px' }">
                            <AppContent />
                        </div>
                    </div>
                    <div v-show="myOutsidenavShow" class="myOutsidenav" @click="closeNav()" key="myOutsidenav"></div>
                </div>
            </div>
        </template>

        <template v-else>
            <AppContent />
        </template>
    </div>
</template>

<script>
import ElMenu from './components/ElMenu/index.vue';
import HeaderNav from './components/HeaderNav.vue';
import AppContent from './components/AppContent.vue';
import watchWindow from '@/hooks/watchWindow';
import { LOCAL_KEY } from '@/constant/dict';
export default {
    extends: watchWindow,
    data() {
        return {
            isOneself: false,
            sidebarHeight: window.innerHeight - 50,
            language: '',
            myOutsidenavShow: false
        };
    },
    components: {
        ElMenu,
        HeaderNav,
        AppContent
    },
    mounted() {
        this.isOneself = this.$route.meta.oneself;
        if (window.innerWidth >= 1274) {
            this.modeFlag = true;
            window.sessionStorage.setItem(LOCAL_KEY.IS_CURRENT_MODE, 'PC');
        } else {
            this.modeFlag = false;
            window.sessionStorage.setItem(LOCAL_KEY.IS_CURRENT_MODE, 'Mobile');
        }
    },
    methods: {
        openNav() {
            this.myOutsidenavShow = true;
            document.getElementsByClassName('myOutsidenav')[0].style.display = 'block';
            document.getElementsByClassName('system-title')[0].style.display = 'flex';
            document.getElementsByClassName('sidebar-container')[0].style.display = 'block';
            this.$forceUpdate();
            window.focus();
        },
        closeNav() {
            this.myOutsidenavShow = false;
            document.getElementsByClassName('myOutsidenav')[0].style.display = 'none';
            document.getElementsByClassName('system-title')[0].style.display = 'none';
            document.getElementsByClassName('sidebar-container')[0].style.display = 'none';
            this.$forceUpdate();
            window.focus();
        }
    },
    watch: {
        $route: function (newVal) {
            this.isOneself = newVal.meta.oneself;
            console.log(newVal);
        }
    }
};
</script>

<style lang="less" scoped>
@import '@/assets/css/theme_blue/layout.less';
#leftBar .system-title .image{
    height: auto !important;
}
</style>
